<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 添加路由链接 -->
        <router-link to="/user">User</router-link>
        <router-link to="/register">Register</router-link>
        <!-- 路由占位符 -->
        <router-view></router-view>
    </div>
    <script src="lib/vue_2.5.22.js"></script>
    <script src="lib/vue-router_3.0.2.js"></script>
    <script>
        // 定义路由组件
        const User = {
            template: '<h1>User 组件</h1>'
        }
        const Register = {
            template: '<h1>Register 组件</h1>'
        }
        // 创建路由实例
        const router = new VueRouter({
            // 配置路由规则
            routes: [
                //路由重定向    
                {
                    path: '/',
                    redirect: '/user'
                }, {
                    path: '/user',
                    component: User
                }, {
                    path: '/Register',
                    component: Register
                }
            ]
        })
        const vm = new Vue({
            el: '#app',
            // 挂载
            router,
            data: {

            }
        })
    </script>
</body>

</html>